<template>
  <div class="baobaotuan">
    <div class="top">
      <div class="title">爆爆团</div>
      <h2>限时爆款 超级低价</h2>
    </div>
    <div class="bottom">
      <p>
        <span
          :class="{ active: optsIndex == index }"
          v-for="(item, index) in optslist"
          :key="index"
          @click="handleClick(index)"
        >
          {{ item }}
        </span>
      </p>
      <div class="baotuanlist">
        <div class="item" v-for="(item, index) in tuanlist" :key="index">
          <div class="left">
            <img :src="item.picture" alt="" />
          </div>
          <div class="right">
            <div class="name">
              {{ item.name }}
            </div>
            <div class="show">
              <div class="show-left">
                <span class="tishi">爆爆团价</span>
                <div>
                  ￥<span class="price">
                    {{ item.min_price }}
                  </span>
                  <span class="zhekou" v-if="item.promotion_info">
                    {{ item.promotion_info }}
                  </span>
                </div>
              </div>
              <div class="show-right">
                <div class="btn">{{ btnText }}</div>
                <div class="sales">
                  {{ item.month_saled_content }}
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { tuan_list } from "../api/index";

export default {
  data() {
    return {
      status: 1,
      optsIndex: 0,
      optslist: ["正在抢购", "上新预告"],
      tuanlist: [],
      btnText: "马上抢",
    };
  },
  methods: {
    handleClick(index) {
      this.optsIndex = index;
      this.status = this.optsIndex == 0 ? 1 : 0;
      tuan_list({ status: this.status }).then((res) => {
        this.tuanlist = res.data.list;
      });
    },
  },
  mounted() {
    tuan_list({ status: 1 }).then((res) => {
      this.tuanlist = res.data.list;
    });
  },
};
</script>

<style scoped>
.baobaotuan {
  height: 550px;
  position: relative;
}
.top {
  height: 220px;
  color: white;
  text-align: center;
  background: linear-gradient(to bottom, red, orange);
}
.title {
  height: 50px;
  line-height: 50px;
  font-weight: 700;
  font-size: 20px;
  font-style: italic;
}
h2 {
  height: 50px;
  line-height: 50px;
}
.bottom {
  width: 340px;
  position: absolute;
  top: 140px;
  left: 50%;
  margin-left: -170px;
}
p {
  height: 30px;
}
p span {
  color: white;
  margin-right: 20px;
  cursor: pointer;
}
p .active {
  font-weight: 700;
}
.baotuanlist {
  height: 380px;
  overflow-y: auto;
}
::-webkit-scrollbar {
  display: none;
}
.item {
  height: 100px;
  background-color: #fff;
  border-radius: 5px;
  display: flex;
  align-items: center;
  margin-bottom: 5px;
}
.left {
  width: 100px;
  height: 100px;
  padding: 10px;
}
.left img {
  width: 100%;
  height: 100%;
  border-radius: 5px;
}
.right {
  width: 260px;
  height: 80px;
}
.name {
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 10px;
}
.show {
  font-size: 12px;
  color: red;
  display: flex;
  justify-content: space-between;
}
.price {
  display: inline-block;
  font-size: 16px;
  margin-top: 5px;
  margin-right: 10px;
}
.zhekou {
  display: inline-block;
  padding: 2px;
  border-radius: 2px;
  border: 1px solid red;
}
.show-right {
  width: 80px;
  text-align: center;
  margin-right: 10px;
}
.btn {
  width: 80px;
  color: white;
  background-color: red;
  height: 30px;
  border-radius: 20px;
  text-align: center;
  line-height: 30px;
  margin-bottom: 5px;
}
</style>